<?php

/**
 * Challenge Cup modloader system file,
 * @author Luke Barratt 
 * @copyright Copyright (C) 2008 by Luke Barratt
 * @license http://www.gnu.org/copyleft/gpl.html
 */

defined('CC_VALID') or 
die('Direct Access to this location is not allowed.'); 

$CC_MODULE = $_GET['mod'];
$CC_GAME_ID = $_GET['game_id'];

echo "<div id=\"teams\">";

if ($CC_GAME_ID == "") 
{
	$CC_NEWS_QUERY = mysql_query("SELECT * FROM cc_users, cc_news WHERE cc_users.user_id = cc_news.news_author ORDER BY cc_news.news_id DESC");
	while ($CC_NEWS_ARRAY = mysql_fetch_assoc($CC_NEWS_QUERY)) 
	{
		echo 
		"<div id=\"news\">
			<div id=\"newsbar\">
				<div id=\"title\">
					<h2>". $CC_NEWS_ARRAY['news_title'] ."</h2>
				</div>
				<div id=\"newsdate\">
					<img src=\"images/nation/". $CC_NEWS_ARRAY['user_nation'] .".gif\" />
					<span id=\"alias\"> ". $CC_NEWS_ARRAY['user_name'] ."</span><br/>". $CC_NEWS_ARRAY['news_date'] ."
				</div>
			</div>
			<div id=\"newscontent\">
				". $CC_NEWS_ARRAY['news_content'] ."
			</div>
		</div>";
	}
	CC_FREE_RESULT($CC_NEWS_QUERY);
}
else
{
	if ($CC_GAME_ID != "") 
	{
		$CC_NEWS_QUERY = mysql_query("SELECT * FROM cc_join, cc_news, cc_game, cc_users WHERE cc_join.join_id_parent = cc_news.news_id AND cc_join.join_id_link = cc_game.game_id AND cc_join.join_type = 'news' AND cc_game.game_id = '{$CC_GAME_ID}' AND cc_news.news_author = cc_users.user_id ORDER BY cc_news.news_id DESC");
		while ($CC_NEWS_ARRAY = mysql_fetch_array($CC_NEWS_QUERY)) 
		{	
			$CC_GAME_ID = $_GET['game_id'];		
			echo "<div id=\"news\">
			<div id=\"newsbar\">
				<div id=\"title\">
					<h2>". $CC_NEWS_ARRAY['news_title'] ."</h2>
				</div>
				<div id=\"newsdate\">
					<img src=\"images/nation/". $CC_NEWS_ARRAY['user_nation'] .".gif\" />
					<span id=\"alias\"> ". $CC_NEWS_ARRAY['user_name'] ."</span><br/>". $CC_NEWS_ARRAY['news_date'] ."
				</div>
			</div>
			<div id=\"newscontent\">
				". $CC_NEWS_ARRAY['news_content'] ."
			</div>
			</div>";
		}
	CC_FREE_RESULT($CC_NEWS_QUERY);
	}
}

?>